/* Title:		
 *
 * Project:     MAS
 *
 * @ Link: 		http://...
 *
 * @ Email:		ivan_ling@hotmail.com
 *
 * @ Copyright: Copyright (c) 2008 mezimedia
 *
 * @ Author 	Ivan.ling
 *
 * @ Version 	1.0
 
 * @ last change time 2008-01-20 	
 */
package com.pub.util;

public class Validate
{
	public static void main(String args[])
	{
		System.out.println("out=== " + Validate.iskDate("2008-08-05"));
	}
	
	public Validate()
	{
	}

	public static boolean isNumber(String strUrl){
		return strUrl.matches("[\\d.]+");
	}

	public static boolean isInteger(String strUrl){
		return strUrl.matches("[\\d]+");
	}
			
	public static boolean isSimpleUrl(String strUrl){
		return strUrl.startsWith("http://");
	}

	public static boolean isUrl(String strUrl){
		return strUrl.matches("http://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?");
	}
	
	public static boolean isUSApostcode(String strUrl){
		return strUrl.matches("[0-9]{5}(-[0-9]{4})?");
	}
		
	public static boolean isIP(String strUrl){
		return strUrl.matches("^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$");
	}
	
	public static boolean isTime(String strUrl){
		return strUrl.matches("(20|21|22|23|[0-1]?\\d):[0-5]?\\d:[0-5]?\\d$");
	}

	public static boolean isDate(String strUrl){
		return strUrl.matches("^[0-1]\\d[-/.][0-3]\\d[-/.]\\d\\d$");
	}
		
	public static boolean isSimpleEmail(String strUrl){
		return strUrl.matches("^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$");
	}
	
	public static boolean isEmail(String strUrl){
		return strUrl.matches("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
	}
	
	public static boolean isNumLetterChinese(String strUrl){
		return strUrl.matches("\\w\\u4e00-\\u9fa5]+");
	}
	
	public static boolean iskDate(String strUrl){
		return strUrl.matches("^((((1[6-9]|[2-9]\\d)\\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\\d|3[01]))|(((1[6-9]|[2-9]\\d)\\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\\d|30))|(((1[6-9]|[2-9]\\d)\\d{2})-0?2-(0?[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$");
	}

	public static boolean isIDcard(String strUrl){
		return strUrl.matches("\\d{15}(\\b|(\\d{3}|\\d{2}(x|y|X|Y))\\b)");
	}
	
}